<?php
require_once ($_SERVER['DOCUMENT_ROOT'] . '/../start.php'); //Подключаем файл инициализации

$uniqueName = $_POST['uniqueName'];

if (file_exists(UPLOAD . $uniqueName . '.png')) {
  echo true;
}
else {
  $wave = new wave(UPLOAD . $uniqueName);
  $chunk = $wave->wavechunk();

  if (! is_array($chunk)) {
    exit('This is not a wav file.');
  }

  if ($chunk['seconds'] > 999) {

    echo "The wav is too long.\r\n\r\n";
    print_r($chunk);

  }
  else {

    set_time_limit(999);

    $im = $wave->waveimage();
    imagepng($im, UPLOAD . $uniqueName . '.png');
  }
  echo true;
} 
?>